<template>
    <div class="sign">
        <div class="loginTitle">欢迎注册账号 <span style="font-family: 华文细黑">:)</span></div>
        <div class="signForm">
            <div class="input userName">
                <div>
                    <i class="bi bi-person-fill mr-3"></i>
                    <div class="d-inline-block">
                        <div class="mb-1">
                            <small class="text-black-50">用户名/ Name</small>
                        </div>
                        <input type="text" v-model="sign.UserName" placeholder="用户名称">
                    </div>
                </div>
            </div>
            <div class="input userEmail">
                <div>
                    <i class="bi bi-envelope-fill mr-3"></i>
                    <div class="d-inline-block">
                        <div class="mb-1">
                            <small class="text-black-50">邮箱/ Email</small>
                        </div>
                        <input type="email" v-model="sign.UserEmail" placeholder="绑定邮箱">
                    </div>
                </div>
            </div>
            <div class="input userPassword">
                <div>
                    <i class="bi bi-key-fill mr-3"></i>
                    <div class="d-inline-block">
                        <div class="mb-1">
                            <small class="text-black-50">密码/ Password</small>
                        </div>
                        <input type="password" v-model="sign.UserPwd" placeholder="密码">
                    </div>
                </div>
            </div>
            <div class="input userGender">
                <div>

                    <div class="d-inline-block">
                        <div class="mb-1">
                            <small class="text-black-50">联系方式/ Phone</small>
                        </div>
                        <el-input v-model="sign.UserPhone" placeholder="请输入手机号" :style="{width: '100%'}"></el-input>
                        <el-button type="primary" @click="message()">点击发送消息</el-button>
                    </div>
                </div>
            </div>
        </div>
        <div class="mt-4" style="text-align: center">
            <el-button type="warning" @click="Singn" round plain> 注 册 账 号 </el-button>
        </div>
    </div>
</template>

<script>
    import $ from "jquery";

    export default {
        name: "toSign",
        data(){
            return{
                sign:{
                    userName:'',
                    userEmail:'',
                    userPassword:'',
                    userTelephone:'',
                    userGender:'1'
                }
            }
        },
        mounted() {
            this.iconColor()
        },
        methods:{
            iconColor(){
                $(".input input").on("focus",function () {
                    $(this).parent().siblings(".bi").addClass("iconColor");
                }).on("blur",function () {
                    $(this).parent().siblings(".bi").removeClass("iconColor")
                })
            },
            Singn:function()
            {
                this.axios
          .post("https://localhost:44347/api/app/p-user/roll",this.sign)
          .then(S =>
          {
            if(S.data==1)
            {
              alert("注册成功");
              this.$router.push("/");
            }
            if(S.data==0)
            {
              alert("注册失败!!!");
            }
          }
          )
            },
             message(){
      this.axios.post('https://localhost:44347/api/app/p-user/message?userPhone='+this.sign.userPhone)
      .then(s=>{
         if(s.data == 1)
         {
           alert('发送成功!');
         }else{
         alert('发送失败!');
         }
       })
     },
        }
    }
</script>

<style scoped>

</style>